package com.crois.barrier.admin.controller;



import com.crois.barrier.admin.entity.LogSend;
import com.crois.barrier.admin.mapstruct.LogSendDtoEntityMapper;
import com.crois.barrier.admin.resp.BarrierResponseWrapper;
import com.crois.barrier.admin.service.ILogSendSvc;
import com.crois.barrier.common.response.BarrierResponseEntity;
import com.crois.barrier.common.utils.UtilsAndCommons;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 15:41 2021/10/27
 */
@RequestMapping(UtilsAndCommons.DEFAULT_BARRIER_ADMIN_LOG_SEND_CONTEXT)
@RestController
public class LogSendCtl {

    @Autowired
    @Qualifier("logSendSvc")
    private ILogSendSvc logSendSvc;

    /***
     * barrier log send list
     */
    @GetMapping(UtilsAndCommons.BARRIER_LIST_CONTEXT)
    public BarrierResponseEntity<List<?>> logSendList(){
        List<LogSend> logSendList = logSendSvc.findLogSendList();
        return BarrierResponseWrapper.okList(LogSendDtoEntityMapper.INSTANCE.toLogSendDtoList(logSendList));
    }
    /***
     * barrier log send detail
     */
    @GetMapping(UtilsAndCommons.BARRIER_DETAIL_CONTEXT+"/{logId}")
    public BarrierResponseEntity<?> logSendList(@PathVariable("logId") Integer logId){
        LogSend logSend = logSendSvc.getById(logId);
        return BarrierResponseWrapper.ok(LogSendDtoEntityMapper.INSTANCE.toLogSendDto(logSend));
    }
}
